package com.cn.jon.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cn.jon.pojo.Student;
import com.cn.jon.service.StudentService;

@Controller
public class StudentController {
	
	@Autowired
	private StudentService studentService;
	
	/**
	 * 查看所有学生信息
	 */
	@RequestMapping("/student")
	public ModelAndView findStudentsList() throws Exception {
		com.mysql.jdbc.Driver a;
		// 从数据看中获取所有学生信息
		List<Student> students = studentService.findStudents();
		System.out.println(students);
		// 设置页面和数据
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("items",students);
		modelAndView.setViewName("/student");
		return modelAndView;
	}
}
